//
//  ViewController.m
//  06-NavigationController
//
//  Created by 402030900@qq.com on 16/7/21.
//  Copyright © 2016年 402030900@qq.com. All rights reserved.
//

#import "ViewController.h"
#import "PushViewController.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithRed:0.964 green:1.000 blue:0.694 alpha:1.000];
    // 设置navigationBar的属性
    // 1.title 标题
    self.title = @"我是标题";
    self.navigationItem.title = @"我是标题,哈哈";
    // 2.titleView 标题视图
    UISegmentedControl * segment = [[UISegmentedControl alloc]initWithItems:@[@"第一页",@"第二页",@"第三页"]];
    // 标题视图,修改 x,y 对视图本身没有影响
    segment.frame = CGRectMake(0, 0,200, 30);
    self.navigationItem.titleView = segment;
    // 3.leftBarButtonItem(自定义)
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"back" style:(UIBarButtonItemStylePlain) target:self action:@selector(comeBack:)];
    // 4.rightBarButtonItem(系统自带)
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:(UIBarButtonSystemItemAdd) target:self action:nil];
    // 5.BarButtonItems
    UIBarButtonItem * barButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"1" style:(UIBarButtonItemStylePlain) target:self action:nil];
    UIBarButtonItem * barButtonItem1 =[[UIBarButtonItem alloc]initWithTitle:@"2" style:(UIBarButtonItemStylePlain) target:self action:nil];
    self.navigationItem.leftBarButtonItems = @[barButtonItem,barButtonItem1];
    // 6.隐藏navigationBar
    self.navigationController.navigationBarHidden = NO;
    self.navigationController.navigationBar.hidden = NO;
    // 7.barStyle
    self.navigationController.navigationBar.barStyle = 0;
//    UIBarStyleDefault          = 0,
//    UIBarStyleBlack            = 1,
    // 8.barTintColor背景颜色
    self.navigationController.navigationBar.backgroundColor = [UIColor redColor];// 半透明
    self.navigationController.navigationBar.barTintColor = [UIColor redColor];// 不透明
    // 9.tintColor bar字体和边框颜色
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    // 10.translucent 半透明效果 NO时 原点从(0,64)开始
    UIButton * button = [UIButton buttonWithType:(UIButtonTypeSystem)];
    [button setFrame:CGRectMake(0, 0, 200, 200)];
    button.backgroundColor = [UIColor colorWithRed:1.000 green:0.694 blue:0.990 alpha:1.000];
        [button addTarget:self action:@selector(clickButton:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.view addSubview:button];

    self.navigationController.navigationBar.translucent = NO;
    // 11. 与translucent效果一样
    self.edgesForExtendedLayout = UIRectEdgeNone;
    // 12. 栈顶视图控制器 self.navigationController.topViewController
    //     可见视图控制器 self.navigationController.visibleViewController
    
    
    
    
    
    
    
    
    // Do any additional setup after loading the view, typically from a nib.
}
-(void)clickButton:(UIButton *)button{
    // 页面跳转 push pop
    // PUSH 入栈 POP 出栈
    [self.navigationController pushViewController:[[PushViewController alloc]init] animated:YES];
   
}
-(void)comeBack:(UIBarButtonItem *)barButtonItem{
    NSLog(@"返回");
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
